import { Component } from '@angular/core';
import { IonicPage, NavController, NavParams } from 'ionic-angular';
import { HttpProvider } from '../../providers/http/http';
import { StorageProvider } from '../../providers/storage/storage';
import { DialogProvider } from '../../providers/dialog/dialog';
/**
 * Generated class for the Applyinput page.
 *
 * See http://ionicframework.com/docs/components/#navigation for more info
 * on Ionic pages and navigation.
 */
@IonicPage()
@Component({
	selector: 'page-costinput',
	templateUrl: 'costinput.html',
})
export class CostinputPage {

	/**
	 * 输入界面控制
	 */
	inputView = {
		applycompany: false, //申请公司
		applyproject: false, //请款项目
		applydepartment: false, //请款部门
		applysharetime: false, //分摊日期
		applyshareproject: false, //分摊项目
		applyamountname: false, //费用名称
		applyapplytime: false, //申请日期
		applyaccruedtime: false, //计提日期
		applyaccruedamount: false, //计提金额
		applyhandler: false, //经办人
		applymaketable: false, //制表人
		applyamount: false, //本次请款金额(大写/小写)
		//
		applyautotype7: false, //按合同约定计提分摊审批
		applyautotype8: false, //各部门分摊审批
		applyautotype9: false, //人工成本计提审批
		applyautotype10: false, //税金计提审批
		//
		applyworkeramount: false, //在职职工工资总额（元）
		applyworkercount: false, //在职职工人数
		applyworkerpercent: false, //应安排残疾人就业比例
		applyworkerpercentcount: false, //实际安排残疾人就业人数
		applyworkerpayamount: false, //本期应缴纳费额（元）
		//
		applybankunitname: false, //收款单位名称
		applybankusername: false, //员工姓名
		applybankno: false, //银行账号
		applybankname: false, //开户银行
		//
		applygeneralnote: false, //综合办领导意见
		applydepartnote: false, //部门领导意见
		applyaccountnote: false, //会计审核意见
		applyleadershipnote: false, //分管领导意见
		applyhandlernote: false, //经办部门意见
		applyofficenote: false, //综合办公室意见
		applyfinancialnote: false, //财务部意见
		applymanagernote: false, //公司总经理意见
		applynextlink: false, //下一步处理环节
		applynextman: false, //下一步处理人
		applyuploadfile: false, //附件
	}
	/**
	 * 输入界面控制
	 */
	inputViewName = {
		applycompany: '申请公司', //申请公司
		applyproject: '请款项目', //请款项目
		applydepartment: '请款部门', //请款部门
		applysharetime: '分摊日期', //分摊日期
		applyshareproject: '分摊项目', //分摊项目
		applyamountname: '费用名称', //费用名称
		applyapplytime: '申请日期', //申请日期
		applyaccruedtime: '计提日期', //计提日期
		applyaccruedamount: '计提金额', //计提金额
		applyhandler: '经办人', //经办人
		applymaketable: '制表人', //制表人
		applyamount: '本次请款金额', //本次请款金额(大写/小写)
		//
		applyworkeramount: '在职职工工资总额(元)', //在职职工工资总额（元）
		applyworkercount: '在职职工人数', //在职职工人数
		applyworkerpercent: '应安排残疾人就业比例', //应安排残疾人就业比例
		applyworkerpercentcount: '实际安排残疾人就业人数', //实际安排残疾人就业人数
		applyworkerpayamount: '本期应缴纳费额(元)', //本期应缴纳费额（元）
		//
		applybankunitname: '收款单位名称', //收款单位名称
		applybankusername: '员工姓名', //员工姓名
		applybankno: '银行账号', //银行账号
		applybankname: '开户银行', //开户银行
		//
		applygeneralnote: '综合办领导意见', //综合办领导意见
		applydepartnote: '部门领导意见', //部门领导意见
		applyaccountnote: '会计审核意见', //会计审核意见
		applyleadershipnote: '分管领导意见', //分管领导意见
		applyhandlernote: '经办部门意见', //经办部门意见
		applyofficenote: '综合办公室意见', //综合办公室意见
		applyfinancialnote: '财务部意见', //财务部意见
		applymanagernote: '公司总经理意见', //公司总经理意见
		//
		applynextlink: '下一步处理环节', //下一步处理环节
		applynextman: '下一步处理人', //下一步处理人
		applyuploadfile: '附件', //附件
	}
	/**
	 * 输入界面控制
	 */
	inputViewModel = {
		applycompany: '', //申请公司
		applyproject: '', //请款项目
		applydepartment: '', //请款部门
		applysharetime: '', //分摊日期
		applyshareproject: '', //分摊项目
		applyamountname: '', //费用名称
		applyapplytime: '', //申请日期
		applyaccruedtime: '', //计提日期
		applyaccruedamount: '', //计提金额
		applyhandler: '', //经办人
		applymaketable: '', //制表人
		applyamountMax: '', //本次请款金额(大写)
		applyamountMin: '', //本次请款金额(小写)
		//
		applyautotype7items: new Array(), //按合同约定计提分摊审批(新增)
		applyautotype8items: new Array(), //各部门分摊审批(新增)
		applyautotype9items: new Array(), //人工成本计提审批(新增)
		applyautotype10items: new Array(), //税金计提审批(新增)
		//
		applyworkeramount: '', //在职职工工资总额（元）
		applyworkercount: '', //在职职工人数
		applyworkerpercent: '', //应安排残疾人就业比例
		applyworkerpercentcount: '', //实际安排残疾人就业人数
		applyworkerpayamount: '', //本期应缴纳费额（元）
		//
		applybankunitname: '', //收款单位名称
		applybankusername: '', //员工姓名
		applybankno: '', //银行账号
		applybankname: '', //开户银行
		//
		applygeneralnote: '', //综合办领导意见
		applydepartnote: '', //部门领导意见
		applyaccountnote: '', //会计审核意见
		applyleadershipnote: '', //分管领导意见
		applyhandlernote: '', //经办部门意见
		applyofficenote: '', //综合办公室意见
		applyfinancialnote: '', //财务部意见
		applymanagernote: '', //公司总经理意见
		applynextlink: '', //下一步处理环节
		applynextman: '', //下一步处理人
		applyuploadfile: '', //附件
	}

	/**
	 * 页面类型
	 */
	private type: Number;
	/**
	 * 标题
	 */
	private title: String;
	/**
	 * 年份
	 */
	private year: String;

	constructor(
		public navCtrl: NavController,
		public navParams: NavParams,
		public http: HttpProvider,
		public storage: StorageProvider,
		public dialog: DialogProvider) {
		this.type = this.navParams.get("type"); //页面类型
		this.year = "2017";
	}

	ionViewDidLoad() {
		console.log('ionViewDidLoad Applyinput');
		//控制显示
		this.ionViewDidShow();
	}

	ionViewDidShow() {
		//1.人工成本支付申请表1
		if(this.type == 1) {
			this.title = '人工成本支付申请表1';
			this.inputView.applycompany = true;
			this.inputView.applyproject = true;
			this.inputView.applydepartment = true;
			this.inputView.applyhandler = true;
			this.inputView.applyamount = true;
			this.inputView.applyofficenote = true;
			this.inputView.applyfinancialnote = true;
			this.inputView.applymanagernote = true;
			this.inputView.applynextlink = true;
			this.inputView.applynextman = true;
			this.inputView.applyuploadfile = true;
		}
		//2.人工成本支付申请表2
		if(this.type == 2) {
			this.title = '人工成本支付申请表2';
			this.inputView.applycompany = true;
			this.inputView.applyproject = true;
			this.inputView.applydepartment = true;
			this.inputView.applyhandler = true;
			this.inputView.applyamount = true;
			this.inputView.applybankunitname = true;
			this.inputView.applybankno = true;
			this.inputView.applybankname = true;
			this.inputView.applyofficenote = true;
			this.inputView.applyfinancialnote = true;
			this.inputView.applymanagernote = true;
			this.inputView.applynextlink = true;
			this.inputView.applynextman = true;
			this.inputView.applyuploadfile = true;
		}
		//3.员工住房公积金支付申请
		if(this.type == 3) {
			this.title = '员工住房公积金支付申请';
			this.inputView.applycompany = true;
			this.inputView.applydepartment = true;
			this.inputView.applyhandler = true;
			this.inputView.applyamount = true;
			this.inputView.applybankusername = true;
			this.inputView.applybankno = true;
			this.inputView.applybankname = true;
			this.inputView.applyofficenote = true;
			this.inputView.applynextlink = true;
			this.inputView.applynextman = true;
			this.inputView.applyuploadfile = true;
		}
		//4.职工教育经费支付申请
		if(this.type == 4) {
			this.title = '职工教育经费支付申请';
			this.inputView.applycompany = true;
			this.inputView.applyproject = true;
			this.inputView.applydepartment = true;
			this.inputView.applyhandler = true;
			this.inputView.applyamount = true;
			this.inputView.applybankusername = true;
			this.inputView.applybankno = true;
			this.inputView.applybankname = true;
			this.inputView.applyhandlernote = true;
			this.inputView.applyofficenote = true;
			this.inputView.applyfinancialnote = true;
			this.inputView.applymanagernote = true;
			this.inputView.applynextlink = true;
			this.inputView.applynextman = true;
			this.inputView.applyuploadfile = true;
		}
		//5.残疾人就业保障金缴纳审批
		if(this.type == 5) {
			this.title = '残疾人就业保障金缴纳审批';
			this.inputView.applycompany = true;
			this.inputView.applymaketable = true;
			this.inputView.applyworkeramount = true;
			this.inputView.applyworkercount = true;
			this.inputView.applyworkerpercent = true;
			this.inputView.applyworkerpercentcount = true;
			this.inputView.applyworkerpayamount = true;
			this.inputView.applyofficenote = true;
			this.inputView.applyfinancialnote = true;
			this.inputView.applymanagernote = true;
			this.inputView.applynextlink = true;
			this.inputView.applynextman = true;
			this.inputView.applyuploadfile = true;
		}
		//6.离退休人员费用支付申请
		if(this.type == 6) {
			this.title = '离退休人员费用支付申请';
			this.inputView.applycompany = true;
			this.inputView.applyproject = true;
			this.inputView.applydepartment = true;
			this.inputView.applyhandler = true;
			this.inputView.applyamount = true;
			this.inputView.applybankunitname = true;
			this.inputView.applybankno = true;
			this.inputView.applybankname = true;
			this.inputView.applyofficenote = true;
			this.inputView.applynextlink = true;
			this.inputView.applynextman = true;
			this.inputView.applyuploadfile = true;
		}
		//7.按合同约定计提分摊审批
		if(this.type == 7) {
			this.title = '按合同约定计提分摊审批';
			this.inputView.applycompany = true;
			this.inputView.applysharetime = true;
			this.inputView.applymaketable = true;
			this.inputView.applyamountname = true;
			this.inputView.applyautotype7 = true;
			this.inputView.applydepartnote = true;
			this.inputView.applyaccountnote = true;
			this.inputView.applyleadershipnote = true;
			this.inputView.applymanagernote = true;
			this.inputView.applynextlink = true;
			this.inputView.applynextman = true;
			this.inputView.applyuploadfile = true;
		}
		//8.各部门分摊审批
		if(this.type == 8) {
			this.title = '各部门分摊审批';
			this.inputView.applycompany = true;
			this.inputView.applymaketable = true;
			this.inputView.applyshareproject = true;
			this.inputView.applyautotype8 = true;
			this.inputView.applydepartnote = true;
			this.inputView.applyleadershipnote = true;
			this.inputView.applymanagernote = true;
			this.inputView.applynextlink = true;
			this.inputView.applynextman = true;
			this.inputView.applyuploadfile = true;
		}
		//9.人工成本计提审批
		if(this.type == 9) {
			this.title = '人工成本计提审批';
			this.inputView.applycompany = true;
			this.inputView.applyaccruedtime = true;
			this.inputView.applyhandler = true;
			this.inputView.applyaccruedamount = true;
			this.inputView.applyautotype9 = true;
			this.inputView.applygeneralnote = true;
			this.inputView.applyfinancialnote = true;
			this.inputView.applymanagernote = true;
			this.inputView.applynextlink = true;
			this.inputView.applynextman = true;
			this.inputView.applyuploadfile = true;
		}
		//10.税金计提审批
		if(this.type == 10) {
			this.title = '税金计提审批';
			this.inputView.applycompany = true;
			this.inputView.applyhandler = true;
			this.inputView.applyapplytime = true;
			this.inputView.applyaccruedtime = true;
			this.inputView.applyautotype10 = true;
			this.inputView.applyfinancialnote = true;
			this.inputView.applymanagernote = true;
			this.inputView.applynextlink = true;
			this.inputView.applynextman = true;
			this.inputView.applyuploadfile = true;
		}
	}

	ionViewDidAddAuto(type) {
		//7.按合同约定计提分摊审批
		if(type == 7) {
			let obj = new Object();
			obj['num'] = this.inputViewModel.applyautotype7items.length + 1;
			obj['mat'] = ''; //分摊事项
			obj['code'] = ''; //合同编号
			obj['amount'] = ''; //合同总额
			obj['service'] = ''; //仓储服务费
			obj['yearamount'] = ''; //{{year}}年预计成本金额
			obj['yeartax'] = ''; //{{year}}年取得可抵扣进项税额
			obj['endtime'] = ''; //合同期限
			obj['everyshare'] = ''; //每月分摊额
			obj['monshare'] = ''; //本月分摊额
			obj['yearmon'] = ''; //本年累计至本月分摊额
			obj['yearmonend'] = ''; //本年累计至本月未分摊额
			obj['note'] = ''; //备注
			this.inputViewModel.applyautotype7items.push(obj);
		}
		//8.各部门分摊审批
		if(type == 8) {
			let obj = new Object();
			obj['num'] = this.inputViewModel.applyautotype8items.length + 1;
			obj['depart'] = '';
			obj['amount'] = '';
			obj['tax'] = '';
			obj['sum'] = '';
			obj['note'] = '';
			this.inputViewModel.applyautotype8items.push(obj);
		}
		//9.人工成本计提审批
		if(type == 9) {
			let obj = new Object();
			obj['num'] = this.inputViewModel.applyautotype9items.length + 1;
			obj['name'] = '';
			obj['value'] = '';
			this.inputViewModel.applyautotype9items.push(obj);
		}
		//10.税金计提审批
		if(type == 10) {
			let obj = new Object();
			obj['num'] = this.inputViewModel.applyautotype10items.length + 1;
			obj['name'] = '';
			obj['value'] = '';
			this.inputViewModel.applyautotype10items.push(obj);
		}
	}
}